﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;

namespace MvcControlToolkit
{
    public static class Config
    {
        public static readonly string MS_AJAX_DIR;
        public static readonly string ACT_VIRTUAL_PATH;

        //added to standardize include syntax across the project
        public static readonly string SCRIPT_INCLUDE_FORMAT = "<script type=\"text/javascript\" language=\"javascript\" src=\"{0}\"></script>";

        static Config()
        {
            //load values
            MS_AJAX_DIR = LoadFromConfig("MS_AJAX_DIR", "/content/");
            ACT_VIRTUAL_PATH = LoadFromConfig("ACT_VIRTUAL_PATH", "/content/ajaxcontroltoolkit/");
        }

        private static string LoadFromConfig(string appSettingName, string defaultValue)
        {
            string settingValue = ConfigurationManager.AppSettings[appSettingName];
            if (string.IsNullOrEmpty(settingValue))
                settingValue = defaultValue;

            return settingValue;
        }
    }
}
